package com.zbkj.front.controller.v2.spread;

import com.zbkj.dal.base.page.CommonPage;
import com.zbkj.dal.base.result.CommonResult;
import com.zbkj.dal.pojo.response.OrderFrontDataResponse;
import com.zbkj.front.model.req.UserScanQrcodeReq;
import com.zbkj.front.service.SpreadService;
import com.zbkj.service.model.front.req.spread.FriendOrderReq;
import com.zbkj.service.model.front.req.spread.SpreadFriendReq;
import com.zbkj.service.model.front.req.spread.SpreadOrderReq;
import com.zbkj.service.model.front.vo.spread.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api("推广v2")
@Slf4j
@RestController
@RequestMapping("/api/front/v2/spread")
public class SpreadController {

    @Resource
    private SpreadService spreadService;

    @ApiOperation(value = "用户推广资金", tags = "推广")
    @GetMapping("/fund")
    public CommonResult<UserSpreadFundVO> userSpreadFund() {
        return CommonResult.success(spreadService.userSpreadFund());
    }

    @ApiOperation(value = "本周战绩", tags = "推广")
    @GetMapping("/week/record")
    public CommonResult<SpreadWeekRecordVO> spreadWeekRecord() {
        return CommonResult.success(spreadService.spreadWeekRecord());
    }

    @ApiOperation(value = "店铺推广二维码", tags = "推广")
    @GetMapping("/merchant/qrcode")
    public CommonResult<String> merchantSpreadQrcode(@RequestParam("merchantId") Integer merchantId) {
        return CommonResult.success(spreadService.merchantSpreadQrcode(merchantId));
    }

    @ApiOperation(value = "用户推广二维码", tags = "推广")
    @GetMapping("/user/qrcode")
    public CommonResult<String> userSpreadQrcode() {
        return CommonResult.success(spreadService.userSpreadQrcode());
    }

    @ApiOperation(value = "用户扫描二维码", tags = "推广")
    @PostMapping("/scan/qrcode")
    public CommonResult<Void> userScanQrcode(@RequestBody UserScanQrcodeReq req) {
        spreadService.userScanQrcode(req);
        return CommonResult.success();
    }

    @ApiOperation(value = "朋友列表", tags = "推广")
    @GetMapping("/friend/list")
    public CommonResult<List<SpreadFriendVO>> friendList(SpreadFriendReq req) {
        return CommonResult.success(spreadService.friendList(req));
    }

    @ApiOperation(value = "朋友详情", tags = "推广")
    @GetMapping("/friend/item")
    public CommonResult<FriendItemVO> friendItem(@RequestParam("userId") Integer userId) {
        return CommonResult.success(spreadService.friendItem(userId));
    }

    @ApiOperation(value = "好友订单", tags = "推广")
    @GetMapping("/friend/order")
    public CommonResult<CommonPage<OrderFrontDataResponse>> friendOrder(FriendOrderReq req) {
        return CommonResult.success(spreadService.friendOrder(req));
    }

    @ApiOperation(value = "推广订单", tags = "推广")
    @GetMapping("/order")
    public CommonResult<CommonPage<SpreadOrderVO>> spreadOrder(SpreadOrderReq req) {
        return CommonResult.success(spreadService.spreadOrder(req));
    }

}
